package Array.MaxProfit;

public class MaxProfit {
    public int maxProfit(int[] prices) {
        if(prices==null || prices.length==0)
            return 0;
        int n=0;
        for(int i=0;i<prices.length-1;i++){
            if(prices[i]<prices[i+1]){
                n+=prices[i+1]-prices[i];
            }
        }
        return n;
    }
}
